/**
 * @author Luc Yriarte
 * 
 * Licence : BSD http://www.opensource.org/licenses/bsd-license.php
 *  
 */
package basicSim;

public class Matrix3D extends Matrix {

	static public Matrix3D MatrixAsMatrix3D(Matrix aMatrix) {
		return new Matrix3D(aMatrix.cell);
	}
	
	/**
	 * Identity
	 */
	public Matrix3D() {
		super(4, 4);
		toId();
	}

	public Matrix3D(double[][] cell) {
		nLines = 4;
		nCols = 4;
		this.cell = cell;
	}

	static public Matrix3D translation(double x, double y, double z) {
		Matrix3D result = new Matrix3D();
		result.cell[0][3] = x;
		result.cell[1][3] = y;
		result.cell[2][3] = z;
		return result;
	}

	static public Matrix3D scale(double x, double y, double z) {
		Matrix3D result = new Matrix3D();
		result.cell[0][0] = x;
		result.cell[1][1] = y;
		result.cell[2][2] = z;
		return result;
	}

	static public Matrix3D rotationX(double teta) {
		Matrix3D result = new Matrix3D();
		result.cell[1][1] = Math.cos(teta);
		result.cell[1][2] = Math.sin(teta);
		result.cell[2][1] = -Math.sin(teta);
		result.cell[2][2] = Math.cos(teta);
		return result;
	}

	static public Matrix3D rotationY(double teta) {
		Matrix3D result = new Matrix3D();
		result.cell[0][0] = Math.cos(teta);
		result.cell[0][2] = -Math.sin(teta);
		result.cell[2][0] = Math.sin(teta);
		result.cell[2][2] = Math.cos(teta);
		return result;
	}

	static public Matrix3D rotationZ(double teta) {
		Matrix3D result = new Matrix3D();
		result.cell[0][0] = Math.cos(teta);
		result.cell[0][1] = Math.sin(teta);
		result.cell[1][0] = -Math.sin(teta);
		result.cell[1][1] = Math.cos(teta);
		return result;
	}

}
